﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FineSoft.Models
{
	public class ExtClass : Class
	{
		public int? ParentIndex;
		private ExtClass _Parent;
		public ExtClass Parent
		{
			get
			{
				if (this._Parent == null)
				{
					if (this.ParentIndex == null)
						return null;
					this._Parent = (ExtClass)InitialData.Classes[this.ParentIndex.Value];
				}
				return this._Parent;
			}
		}

		public virtual string[] AlternateNames { get; set; }
		public virtual Config[] Configs { get; set; }
		public Event[] Events;

		private Config[] _RequiredConfigs;
		public Config[] RequiredConfigs
		{
			get
			{
				if (this._RequiredConfigs == null)
					this._RequiredConfigs = this.Configs.Where(c => c.Required).ToArray();
				return this._RequiredConfigs;
			}
		}

		private string _ShortName;
		public string ShortName
		{
			get
			{
				if (this._ShortName == null)
					this._ShortName = this.Name.Substring(this.Name.LastIndexOf('.') + 1);
				return this._ShortName;
			}
		}
	}
}